package com.vitech.javacertification.oo;

public class CovariantTest {

	public A getObject() {

		System.out.println("getObject from super A");
		return new A();
	}

	public static void main(String[] args) {

		CovariantTest c1 = new SubCovariantTest();
		
		B obj = (B) c1.getObject();
		
		System.out.println(obj.x);

	}
}

class SubCovariantTest extends CovariantTest {

	public B getObject() {

		System.out.println("getObject from extended B");
		return new B();

	}
}

class A {

	int x = 5;
}

class B extends A {

	int x = 6;
}